<?php

namespace Modules\Admin\Http\Controllers;

use Illuminate\Support\Facades\Request;
use Modules\Admin\Service\ActivityService;

class ActivityController extends BaseController
{

    /**
     *  获取所有的活动列表
     *  hinq 2020 3 9
     *
     **/
    public function index()
    {
        $arr_search = (array)Request::all();
        $arr_list = ActivityService::get_list((array)$arr_search);
        echo_error($arr_list);
        return view('admin::activity.index', $arr_list['data']);
    }


    /**
     *    添加活动试图
     *    hinq 2019 10 21
     *
     **/
    public function create()
    {
        return view('admin::activity.create', []);
    }


    /**
     *    添加活动数据
     *    hinq 2019 10 21
     *
     **/
    public function store()
    {
        $arr_input = (array)Request::all();
        return ActivityService::add_one((array)$arr_input);
    }


    /**
     *    添加活动的商品信息视图
     *    hinq 2019 10 21
     *
     **/
    public function goods_create()
    {
        $nId = (int)Request::get('id');
        //获取已添加的商品模块
        $goods_list = ActivityService::get_goods_list_to_activity((int)$nId);
        return view('admin::activity.goods_create', ['id' => $nId, 'info' => $goods_list]);
    }


    /**
     *    获取活动的商品列表
     *    hinq 2019 10 21
     *
     **/
    public function goods_list()
    {
        $nId = (int)Request::get('id');
        $arr_list = ActivityService::get_goods_list((int)$nId);
        return $arr_list;
    }


    /**
     *    添加活动的商品数据
     *    hinq 2019 10 21
     *
     **/
    public function goods_list_store()
    {
        $arr_input = (array)Request::all();
        return ActivityService::goods_list_store((array)$arr_input);
    }


    /**
     *    强制禁用活动（不可恢复到正常状态）
     *    hinq 2019 10 23
     *
     **/
    public function change_status()
    {

        $nId = (int)Request::get('id');
        return ActivityService::change_status((int)$nId);
    }


    /**
     *    删除活动的商品模块
     *    hinq 2019 10 23
     *
     **/
    public function activity_goods_del()
    {
        $nId = (int)Request::get('id');
        return ActivityService::del_one((int)$nId);
    }


    /**
     *    活动详情信息
     *    hinq 2019 10 25
     *
     **/
    public function detail()
    {
        $nId = (int)Request::get('id');
        //获取当前活动的信息
        $arr_list = ActivityService::get_one((int)$nId);
        return view('admin::activity.detail', ['data' => $arr_list]);
    }


    /**
     *    活动详情获取活动相关的订单列表
     *    hinq 2019 10 26
     *
     **/
    public function order_list()
    {
        $nId = (int)Request::get('activity_id');
        $arr_list = ActivityService::get_order_list((int)$nId);
        return $arr_list;
    }
}
